package javaBase.nowcoder.HJ25_S_数据分类处理;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class MainMe {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s1 = br.readLine();
        String s2 = br.readLine();
        s2 = s2.substring(s2.indexOf(" ")).trim();
        List<String> listR = (List<String>) Arrays.stream(s1.split(" ")).collect(Collectors.toList());
        List<String> listI = (List<String>) Arrays.stream(s2.split(" ")).distinct().sorted((o1, o2) -> {
            return Integer.parseInt(o1) - Integer.parseInt(o2);
        }).collect(Collectors.toList());

        StringBuilder index_value = new StringBuilder();
        Integer num = 0;
        for (int i = 0; i < listI.size(); i++) {
            StringBuilder sb = new StringBuilder("");
            Integer count = 0;
            for (int j = 1; j < listR.size(); j++) {
                if (listR.get(j).indexOf(listI.get(i)) != -1) {
                    sb.append(" ").append(j - 1).append(" ").append(listR.get(j));
                    count++;
                }
            }
            if (count != 0) {
                index_value.append(" ").append(listI.get(i)).append(" ").append(count).append(sb);
                num += (count + 1) << 1;
            }
        }
        System.out.println(num + "" + index_value);
    }
}
//   3 6 0 123 3 453 7 3 9 453456 13 453 14 123 6 7 1 456 2 786 4 46 8 665 9 453456 11 456 12 786
//30 3 6 0 123 3 453 7 3 9 453456 13 453 14 123 6 7 1 456 2 786 4 46 8 665 9 453456 11 456 12 786